/*
 *  Copyright (C) 2006 Takeharu KATO
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#ifndef COMMON_H
#define COMMON_H
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <glib.h>
#include <gnome.h>
#include <syslog.h>
#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif
#include "ipmsg.h"
#include "udp.h"
#include "message.h"
#include "userdb.h"
#include "hostinfo.h"
#include "msginfo.h"
#include "logfile.h"
#include "menu.h"
#include "fileattach.h"
#include "tcp.h"
#include "netcommon.h"
#include "fuzai.h"
#include "copying.h"
#include "uicommon.h"
#include "sound.h"
#include "systray.h"
#include "downloads.h"
#include "codeset.h"
#include "protocol.h"
#include "msgout.h"
#include "private.h"
#include "compat.h"
#include "util.h"
#include "cryptcommon.h"

extern udp_con_t *udp_con;

#define STATUS_ICON_WAIT_MICRO_SEC ((1UL)*(1000UL)*(1000UL))
#define IPMSG_COMMON_MAX_RETRY (20)
#define MSG_WATCH_INTERVAL (500)
#define IPMG_LOCK_FILE "/tmp/g2ipmsg.lock"
#define IPMSG_KEY_BTN_CHATTER_MS (300)
#define USERLIST_PRIO_MIN        (-1)
#define USERLIST_DEFAULT_PRIO    (0)
#define USERLIST_PRIO_MAX        (4)

#define prio_is_valid(prio_val)  ( (prio_val>=USERLIST_PRIO_MIN) && \
				   (prio_val<=USERLIST_PRIO_MAX) )


#define IPMSG_BUFSIZ 0x1000
#define _MSG_BUF_SIZE 65536
#define _MSG_BUF_MIN_SIZE ((_MSG_BUF_SIZE)/2)
#if defined(USE_OPENSSL)
#define G2IPMSG_DEFAULT_ENTRY_FLAGS (IPMSG_FILEATTACHOPT|IPMSG_ENCRYPTOPT)
#define G2IPMSG_DEFAULT_SEND_FLAGS  (IPMSG_SENDCHECKOPT|IPMSG_ENCRYPTOPT)
#else
#define G2IPMSG_DEFAULT_ENTRY_FLAGS (IPMSG_FILEATTACHOPT)
#define G2IPMSG_DEFAULT_SEND_FLAGS  (IPMSG_SENDCHECKOPT)
#endif
#define G2IPMSG_DEFAULT_HOST_LIST_LEN 1

int init_ipmsg(void);
void cleanup_ipmsg(void);
int create_lock_file(void);
int release_lock_file(void);

#endif
